Skip to content
/ fluX Public
forked from italoadler/fluX

A javascript engine for generative music in the browser.

License

Notifications You must be signed in to change notification settings

adsrLAB/fluX

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fluX

A javascript engine for generative music in the browser. Check it out "in action" ➫ https://pd3v.github.io/

How to use it

Add references into your website project,

<script type="text/javascript" src="sequencer.js"></script>
<script type="text/javascript" src="generator.js"></script>
<script type="text/javascript" src="synth.js"></script>
<script type="text/javascript" src="midiout.js"></script>
<script type="text/javascript" src="helpers.js"></script>

and then use it in your code like this,

// Using helper functions round(), rand(), countTo() and countFrom()
const CMinorScale = {c:0, d:2, ef:3, f:5, g:7, af:8, bb:10};
const scaleLength = Object.values(CMinorScale).length;

let ascending = true;

const f = _ => {
  const ascDescFlag = round(rand(0,countTo(scaleLength-1)));

  if (ascDescFlag == 0 || ascDescFlag == round(scaleLength/2)) {
    ascending = !ascending;
  }

  if (ascending) {
    return {note: countTo(scaleLength-1), vel:countTo(scaleLength-1)>=2 && countTo(scaleLength-1)<=4? 127: 39, dur:8, oct: 4};
  } else {
    return {note:countFrom(scaleLength-1), vel:countFrom(scaleLength-1)>=2 && countFrom(scaleLength-1)<=4? 15: 127, dur:1, oct:2};
  }
}

Sequencer.audioContext = ac;
// to send those notes to your favorite soft/hard synth
Sequencer.generator(CMinorScale, f).midiOut('midi port1').start(120);

// to send those same notes to fluX's synth 'Synth'
//Sequencer.generator(CMinorScale, f).synth('Synth').start(120);

About

A javascript engine for generative music in the browser.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%