dimitriaatos / generative-radio

An online radio station that generates music by playing sounds hosted on Freesound

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generative radio

A browser module that generates music by playing sounds hosted on Freesound.

Demo

http://loskop.radio/generative-radio/

Installation

npm i dimitriaatos/generative-radio

(You'll have to have node and git installed)

Try

git clone https://github.com/dimitriaatos/generative-radio.git
cd generative-radio
npm i
echo "TOKEN=[API token]" > .env
npm test

Replace [API token] with a Freesound API token, you can get one on https://freesound.org/apiv2/apply/.

Use

index.js

import GenerativeRadio from 'generative-radio'
import pieces from './pieces'

const gen = new GenerativeRadio(pieces)

gen.token = '[API token]'

// gen.play() should be called after a user gesture (e.g. a click).
document.addEventListener('click', () => { gen.play() })

pieces.js

export {
  pieces: [
    {
      elements:[
        {
          search: { text: 'rain' },//play a raining sounds
          structure: { metro: 2 } // every 2 seconds
        },
        {
          search: {
            text: 'scream',
            options: {
              results: 50,
              filter: { duration: [0, 60] }, // [min, max] (seconds)
              sort: 'rating_desc' // get the first 50 best rated sounds
            }
          },
          structure: { metro: 10 } // every 10 seconds
        },
      ],
      duration: 10
    },
    {
      elements:[
        {
          search: {
            sound: 339809, // sound id
            options: {
              filter: { duration: [0, '*'] } // no upper limit
            }
          },
          structure: {
            metro: 1,
            fade: 0.2 // sound duration percentage to be faded in and out (max: 0.5)
          }
        },
        {
          search: { text: 'train' },
          structure: { metro: 2 }
        },
      ],
      duration: 60,
      fade: 30 // duration of the piece's fade in and fade out (added to the total duration)
    }
  ]
}

About

An online radio station that generates music by playing sounds hosted on Freesound


Languages

Language:JavaScript 91.0%Language:TypeScript 5.3%Language:HTML 3.7%