Last active
May 11, 2022 04:18
-
-
Save YusukeIwaki/a13b24b125db05c5857d4e6b15420265 to your computer and use it in GitHub Desktop.
fukuoka.rb 0x100 LT demo
This file contains hidden or 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
require 'osc-ruby' | |
def play(sound) | |
client = OSC::Client.new('localhost', 51235) | |
client.send(OSC::Message.new('/run-code', 'DEMO', "play #{sound}")) | |
end | |
require 'concurrent' | |
def kaeru | |
Concurrent::Promises.future do | |
# かーえーるーのーうーたーがーー | |
play(60) | |
sleep 0.4 | |
play(62) | |
sleep 0.4 | |
play(64) | |
sleep 0.4 | |
play(65) | |
sleep 0.4 | |
play(64) | |
sleep 0.4 | |
play(62) | |
sleep 0.4 | |
play(60) | |
sleep 0.8 | |
# きーこーえーてーくーるーよーー | |
play(64) | |
sleep 0.4 | |
play(65) | |
sleep 0.4 | |
play(67) | |
sleep 0.4 | |
play(69) | |
sleep 0.4 | |
play(67) | |
sleep 0.4 | |
play(65) | |
sleep 0.4 | |
play(64) | |
sleep 0.8 | |
# ぐわーx4 | |
4.times { | |
play(60) | |
sleep 0.8 | |
} | |
# げげげげげげげげぐわぐわぐわ | |
play(60) | |
sleep 0.2 | |
play(60) | |
sleep 0.2 | |
play(62) | |
sleep 0.2 | |
play(62) | |
sleep 0.2 | |
play(64) | |
sleep 0.2 | |
play(64) | |
sleep 0.2 | |
play(65) | |
sleep 0.2 | |
play(65) | |
sleep 0.2 | |
play(64) | |
sleep 0.4 | |
play(62) | |
sleep 0.4 | |
play(60) | |
sleep 0.8 | |
end | |
end | |
Concurrent::Promises.zip( | |
kaeru, | |
Concurrent::Promises.future { sleep 3.2 ; kaeru.value! }, | |
Concurrent::Promises.future { sleep 6.4 ; kaeru.value! }, | |
).value! |
This file contains hidden or 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
require 'osc-ruby' | |
def play(sound) | |
client = OSC::Client.new('localhost', 51235) | |
client.send(OSC::Message.new('/run-code', 'DEMO', "play #{sound}")) | |
end | |
require 'concurrent' | |
def main_concurrent | |
# ポーニョポーニョポニョさかなのこ | |
Concurrent::Promises.future { | |
play(72) | |
sleep 0.4 | |
play(69) | |
sleep 0.2 | |
play(65) | |
sleep 0.4 | |
play(60) | |
sleep 0.2 | |
play(60) | |
sleep 0.2 | |
play(60) | |
sleep 0.2 | |
play(62) | |
sleep 0.2 | |
play(65) | |
sleep 0.2 | |
play(70) | |
sleep 0.2 | |
play(74) | |
sleep 0.2 | |
play(72) | |
sleep 0.4 | |
} | |
end | |
def main2_concurrent | |
# あおい、うみから、やってきたー | |
Concurrent::Promises.future { | |
sleep 0.2 | |
play(69) | |
sleep 0.2 | |
play(70) | |
sleep 0.2 | |
play(67) | |
sleep 0.4 | |
play(70) | |
sleep 0.2 | |
play(69) | |
sleep 0.2 | |
play(65) | |
sleep 0.4 | |
play(69) | |
sleep 0.2 | |
play(67) | |
sleep 0.2 | |
play(62) | |
sleep 0.2 | |
play(64) | |
sleep 0.2 | |
play(65) | |
sleep 0.2 | |
play(67) | |
sleep 0.4 | |
} | |
end | |
def sub1_concurrent | |
Concurrent::Promises.future { | |
play(69) | |
sleep 0.4 | |
play(65) | |
sleep 0.2 | |
play(65) | |
sleep 0.4 | |
play(60) | |
sleep 0.2 | |
play(57) | |
sleep 0.2 | |
play(60) | |
sleep 0.2 | |
play(58) | |
sleep 0.2 | |
play(62) | |
sleep 0.2 | |
play(58) | |
sleep 0.2 | |
play(62) | |
sleep 0.2 | |
play(65) | |
} | |
end | |
def base_concurrent | |
Concurrent::Promises.future { | |
8.times do | |
play(53) | |
sleep 0.2 | |
end | |
4.times do | |
play(58) | |
sleep 0.2 | |
end | |
play(53) | |
} | |
end | |
require 'async' | |
def main_async | |
Async do |t| | |
play(72) | |
t.sleep 0.4 | |
play(69) | |
t.sleep 0.2 | |
play(65) | |
t.sleep 0.4 | |
play(60) | |
t.sleep 0.2 | |
play(60) | |
t.sleep 0.2 | |
play(60) | |
t.sleep 0.2 | |
play(62) | |
t.sleep 0.2 | |
play(65) | |
t.sleep 0.2 | |
play(70) | |
t.sleep 0.2 | |
play(74) | |
t.sleep 0.2 | |
play(72) | |
t.sleep 0.4 | |
end | |
end | |
def sub1_async | |
Async do |t| | |
play(69) | |
t.sleep 0.4 | |
play(65) | |
t.sleep 0.2 | |
play(65) | |
t.sleep 0.4 | |
play(60) | |
t.sleep 0.2 | |
play(57) | |
t.sleep 0.2 | |
play(60) | |
t.sleep 0.2 | |
play(58) | |
t.sleep 0.2 | |
play(62) | |
t.sleep 0.2 | |
play(58) | |
t.sleep 0.2 | |
play(62) | |
t.sleep 0.2 | |
play(65) | |
end | |
end | |
def base_async | |
Async do |t| | |
8.times do | |
play(53) | |
t.sleep 0.2 | |
end | |
4.times do | |
play(58) | |
t.sleep 0.2 | |
end | |
play(53) | |
end | |
end | |
Concurrent::Promises.zip( | |
main_concurrent, | |
sub1_concurrent, | |
base_concurrent, | |
).value! | |
main2_concurrent.value! | |
# Async { | |
# main_async | |
# sub1_async | |
# base_async | |
# } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment