npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

riffplay

v1.0.4

Published

Create link to riff

Downloads

15

Readme

riffplay

Play user defined sequence.

Example page

<html>
 <head>
  <script src="https://surikov.github.io/riffplay/riffplay_module.js"></script>
 </head>
 <body>
  <h1>test</h1>
  <p><a id='linktest' href='#'>click</a>
  <script>
   var tempo = '120';
   var drums = [{"drum":0,"beat":0}, {"drum":5,"beat":0}
      ,{"drum":2,"beat":4}, {"drum":5,"beat":4}
      ,{"drum":0,"beat":8}, {"drum":5,"beat":8}
      ,{"drum":2,"beat":12},{"drum":5,"beat":12}
      ];
   var notes = [{"track":5,"beat":0 ,"length":2,"shift":0,"pitch":9}
      ,{"track":5,"beat":4 ,"length":2,"shift":0,"pitch":4}
      ,{"track":5,"beat":8 ,"length":2,"shift":0,"pitch":9}
      ,{"track":5,"beat":12,"length":2,"shift":0,"pitch":4}
      ];
   var songlink = encodeRiffURL(tempo,drums,notes);
   document.getElementById('linktest').onclick=function(){
    console.log(songlink);
    window.open(songlink);
   };
  </script>
 </body>
</html>

Live example

See live example https://surikov.github.io/riffplay/test.html

How to use

Main function

var songlink = encodeRiffURL(tempo,drums,notes);

Parameters:

  • tempo - BPM
  • drums - array of drum notes
    • drum - id of drum (see below)
    • beat - step in 16th's
  • notes - array of instrument notes
    • track - id of instrument (see below)
    • beat - step in 16th's
    • length - duration in 16th's
    • shift - pitch slide in halftones
    • pitch - note pitch

Return

URL with encoded playable melody. Use this URL as a link.

Example - https://surikov.github.io/RiffShareAndroid/app/src/main/assets/load.html?riff=120-77777777-66666666-0a0a0a0a0a0a0a0a0a0a-0001010140104110a011a111-0050209400450204400850209400c5020440

Tempo

tempo is 80-240

Drum IDs

0.Bass drum 1.Low Tom 2.Snare drum 3.Mid Tom 4.Closed Hi-hat 5.Open Hi-hat 6.Ride Cymbal 7.Splash Cymbal

Instrument IDs

0.Distortion guitar 1.Acoustic guitar 2.Percussive Organ 3.PalmMute guitar 4.Acoustic Piano 5.Bass guitar 6.String Ensemble 7.Synth Bass

Human readable names

Use this code

   var C=0,Cs=1,D=2,Ds=3,E=4,F=5,Fs=6,G=7,Gs=8,A=9,As=10,B=11;
   var O=12;
   //
   var BassDrum=0;
   var LowTom=1;
   var SnareDrum=2;
   var MidTom=3;
   var ClosedHiHat=4;
   var OpenHiHat=5;
   var RideCymbal=6;
   var SplashCymbal=7;
   //
   var DistortionGuitar=0;
   var AcousticGuitar=1;
   var PercussiveOrgan=2;
   var PalmMuteGuitar=3
   var AcousticPiano=4;
   var BassGuitar=5
   var StringEnsemble=6;
   var SynthBass=7;

Example of melody definition

 var tempo = '120';
 var drums = [{"drum":BassDrum,"beat":0},{"drum":OpenHiHat,"beat":0}
    ,{"drum":SnareDrum,"beat":4},{"drum":ClosedHiHat,"beat":4}
    ,{"drum":MidTom,"beat":7},{"drum":ClosedHiHat,"beat":7}
    ,{"drum":BassDrum,"beat":8},{"drum":OpenHiHat,"beat":8}
    ,{"drum":SnareDrum,"beat":12},{"drum":ClosedHiHat,"beat":12}
    ,{"drum":LowTom,"beat":15},{"drum":ClosedHiHat,"beat":15}
    ];
 var notes = [{"track":BassGuitar,"beat":0 ,"length":8,"shift":0,"pitch":E+O*0},{"track":PercussiveOrgan,"beat":0 ,"length":4,"shift":0,"pitch":B+O*1},{"track":PercussiveOrgan,"beat":0 ,"length":4,"shift":0,"pitch":E+O*2}
    ,{"track":PercussiveOrgan,"beat":7 ,"length":1,"shift":0,"pitch":E+O*2},{"track":PercussiveOrgan,"beat":7 ,"length":1,"shift":0,"pitch":G+O*2}
    ,{"track":BassGuitar,"beat":8 ,"length":8,"shift":0,"pitch":G+O*0},{"track":PercussiveOrgan,"beat":8 ,"length":4,"shift":0,"pitch":E+O*2},{"track":PercussiveOrgan,"beat":8 ,"length":4,"shift":0,"pitch":G+O*2}
    ,{"track":PercussiveOrgan,"beat":15 ,"length":1,"shift":0,"pitch":As+O*1},{"track":PercussiveOrgan,"beat":15 ,"length":1,"shift":0,"pitch":Ds+O*2}
    ];
 var songlink = encodeRiffURL(tempo,drums,notes);

Live example

See live example https://surikov.github.io/riffplay/test2.html

NPM

  "dependencies": {
    "riffplay": "^1.0.3"
  }
var m = require('riffplay');
var songlink = encodeRiffURL(tempo, drums, notes);

Embedded code

https://jsbin.com/dulupib/edit?html,output