I hereby claim:
- I am fuxoft on github.
- I am fuxoft (https://keybase.io/fuxoft) on keybase.
- I have a public key whose fingerprint is 2AB6 F924 915E 497D D15D 74D5 DA10 6F1F 0BA0 6F67
To claim this, I am signing this object:
------------------------------------------------ | |
-- Script by PaRaDoX. -- | |
-- http://pokemon-project.com -- | |
------------------------------------------------ | |
local coords = { | |
ttilde={x=7,y=30}, | |
t1={x=32,y=30}, | |
t2={x=49,y=30}, | |
t3={x=66,y=30}, |
function OnEvent (event, arg) | |
if (event == "G_PRESSED" and arg == 5) then | |
for num = 0, 9999 do | |
PressAndReleaseKey ("e") | |
Sleep(1) | |
for chr in string.gmatch(string.format("%04d",num),".") do | |
PressAndReleaseKey(chr) | |
Sleep(1) | |
end | |
if IsModifierPressed("rshift") then |
#!/usr/bin/env lua5.3 | |
local ALLOWED = {} | |
for chr in string.gmatch("ABCDEFHIJKLMNOPRSTUVXYZ0123456789",".") do | |
ALLOWED[chr] = true | |
end | |
local SAMOHLASKY = {} | |
for chr in string.gmatch("AEIOUY",".") do | |
SAMOHLASKY[chr] = true |
(defn generator | |
[] | |
(def factory @{}) | |
(def generator-fun | |
(fn [output] | |
(ev/give output :stream-start) | |
(ev/give output 0) | |
(ev/give output :stream-end))) | |
(put factory :generate | |
(fn [self batch] |
I hereby claim:
To claim this, I am signing this object:
# Sound device for Chromebook: hw:CARD=SoundCard,DEV=0 | |
(def sample-rate 48000) | |
(defn is-generator? [x] | |
(and (dictionary? x) (x :is-generator))) | |
(defn- msg-format [args] | |
(string/join | |
(map | |
(fn [thing] |
I will try to explain in greater detail what I am trying to achieve and why I thought coroutines would be great for that. (This is a continuation of the previous thread called "Garbage collected coroutines?" which I am unable to reply to.)
I am experimenting with a way to generate musical waveforms using scripts. The script generates random melodies, renders them as tones, mixes those tones together and writes the resulting music to WAV file (or plays it directly using aplay on Linux).
So, the output of my script is a waveform consisting of 48000 samples per second.
Previously I've experimented with this in Lua a Janet where I was able to do the following:
There is an endless loop, let's call it "audio-out" that writes the resulting WAV file to disk (or plays it in semi-realtime).
#!/usr/bin/picolisp /usr/lib/picolisp/lib.l | |
(setq Uniq | |
(pipe | |
(prog | |
(zero X) | |
(loop | |
(pr (list "unique counter" (inc 'X))) ) ) ) ) | |
(if (fork) |
#!/usr/bin/picolisp /usr/lib/picolisp/lib.l | |
# date.sh and date2.sh are shell scripts that endlessly generate a line of text every few seconds | |
(setq In1 (pipe (exec './date.sh))) | |
(setq In2 (pipe (exec './date2.sh))) | |
(task In1 | |
(in @ (println 'task1 @ (line T)))) |
#!/usr/bin/picolisp /usr/lib/picolisp/lib.l | |
(scl 12) | |
(load "@lib/math.l") | |
(def '2pi (+ pi pi)) | |
# Returns 0.01 for note 69.0, i.e. is hardcoded for 44.1 kHz sample rate | |
(de noteToStep (Note.) | |
~(assert (> Note. 0.1)) | |
(*/ (pow 2.0 (*/ 1.0 Note. 12.0)) 0.0001858136117 1.0)) |