Created
March 15, 2021 02:33
-
-
Save interstar/699a277fa7e766209d729c9010ce2a49 to your computer and use it in GitHub Desktop.
ByteBeats in Edison (FL Studio Sample Editor)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
script "JavaScript ByteBeats" language "javascript"; | |
function generator(t) { | |
return (128&t*(4|7&t>>13)>>(1&-t>>11))+(127&t*(t>>11&t>>13)*(3&-t>>9)) ; | |
} | |
function makeSample(length,srate,norm) { | |
var start = 0; | |
var end = 0; | |
var s; | |
switch(srate) { | |
case 0: | |
EditorSample.Samplerate=8000; | |
break; | |
case 1: | |
EditorSample.Samplerate=11025; | |
break; | |
case 2: | |
EditorSample.Samplerate=22050; | |
break; | |
default: | |
EditorSample.Samplerate=44100; | |
} | |
if (EditorSample.Length<=0) { | |
EditorSample.Length = Round(EditorSample.MsToSamples(length*1000)); | |
} | |
Editor.GetSelectionS(start, end); | |
for (var n = start; n <= end; n++) { | |
for (var c = 0; c < EditorSample.NumChans; c++) { | |
s = generator(n) % 255; | |
EditorSample.SetSampleAt(n, c, s); | |
} | |
} | |
if (norm==0) { | |
EditorSample.NormalizeFromTo(start,end,0.8); | |
} | |
} | |
var Form = CreateScriptDialog("ByteBeats", "Generate Your ByteBeats Right Now!!!"); | |
try { | |
Form.AddInputKnob("Length", 1, 0, 100); | |
Form.AddInputCombo("SampleRate", "8000,11025,22050,44100", 0); | |
Form.AddInputCombo("Normalize?", "Yes,No", 0); | |
if (Form.Execute()) { | |
makeSample(Form.GetInputValue("Length"),Form.GetInputValue("SampleRate"),Form.GetInputValue("Normalize?")); | |
} | |
} finally { | |
Form.Free(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment