Code Monkey home page Code Monkey logo

mm-components's Introduction

Music Markup Web Components

Music Markup Web Components are built using StencilJS and distributed as web components (currently not using Shadow DOM);

The idea behind it is to provide some general markup for creating music instruments and visualisations using web components.

Currently there are three components:

<mm-context>

This is the top level tag to use to create the audio context. You can provide an alternative-context if you want to provide your own AudioContext, otherwise it will create a shared one for the application

<mm-keyboard>

The <mm-keyboard> tag provides an audio context for creating a keyboard element. It takes one property at the moment oscillator-type, which can be one of sine, square, sawsawtooth or triangle. Inside you attach via a single slot any keys you want to bind. The mm-keyboard listens for real keyboard events as well as events from virtual keys. Currently it also provides the wave form picker.

<mm-key>

The <mm-key> tag is used to add a key to the keyboard. You can provide it a frequency and time for the note, and you can also pass a class-name property to pass down custom classes.

In the current example it's used like this

<mm-context>
  <mm-keyboard oscillator-type="sawtooth">
    <mm-key class-name="white b" frequency="174.614" time="1"></mm-key>
    <mm-key class-name="black as" frequency="184.997" time="1"></mm-key>
    <mm-key class-name="white a" frequency="195.998" time="1"></mm-key>
    <mm-key class-name="black gs" frequency="200.000" time="1"></mm-key>
    <mm-key class-name="white g" frequency="207.652" time="1"></mm-key>
    <mm-key class-name="black fs" frequency="233.082" time="1"></mm-key>
    <mm-key class-name="white f" frequency="246.942" time="1"></mm-key>
    <mm-key class-name="white e" frequency="261.626" time="1"></mm-key> <!-- Middle c -->
    <mm-key class-name="black ds" frequency="277.183" time="1"></mm-key>
    <mm-key class-name="white d" frequency="293.665" time="1"></mm-key>
    <mm-key class-name="black cs" frequency="311.127" time="1"></mm-key>
    <mm-key class-name="white c" frequency="329.628" time="1"></mm-key>
  </mm-keyboard>
</mm-context>

Future features include:

  • Adding support for MP3 Audio / WAV files
  • Provide theme support (Design different skins)
  • Add a visualiser for control
  • Support nested tags that provide node pass throughs

Getting Started

To start a new project mm-components uses the Stencil starter

git clone https://github.com/tanepiper/mm-components.git mm-components
cd mm-components
git remote rm origin

and run:

npm install
npm start

To view the build, start an HTTP server inside of the /www directory.

To watch for file changes during development, run:

npm run dev

To build the app for production, run:

npm run build

To run the unit tests once, run:

npm test

To run the unit tests and watch for file changes during development, run:

npm run test.watch

mm-components's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

mm-components's Issues

npm run build won't work

Run the following command and get the output below:

โžœ  mm-webcomponents git:(master) npm run build

> @stencil/[email protected] build /home/tane/work/mm-webcomponents
> stencil build --prerender

[50:24.8]  @stencil/core v0.0.9-4 
[50:24.8]  build, app, prod mode, started ... 
[50:24.8]  compile started ... 
[50:26.4]  compile finished in 1.67 s 
[50:26.4]  bundle styles started ... 
[50:26.4]  bundle modules started ... 
[50:26.5]  bundle styles finished in 85 ms 
[50:26.6]  bundle modules finished in 108 ms 
[50:26.6]  generate es2015 bundles started ... 
[50:26.6]  generate es2015 bundles finished in 71 ms 
[50:26.6]  generate es5 bundles started ... 
[50:26.7]  generate es5 bundles finished in 46 ms 
[50:28.4]  prerendering started ... 
[50:28.4]  prerender, started: / ... 
[50:28.7]  prerender, finished: / in 317 ms 
[50:28.8]  prerendered urls: 1 in 348 ms 
[50:28.8]  generate service worker started ... 
[50:28.8]  generate service worker finished in 32 ms 

[ ERROR ]  Runtime error detected during componentDidLoad(): mm-keyboard
           AudioContext is not defined 

[50:28.8]  build finished in 4.04 s

Tried to add @types/webaudioapi to the project, got lots of duplication errors.

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.