-
Notifications
You must be signed in to change notification settings - Fork 2
/
sounds.rb
66 lines (53 loc) · 1.31 KB
/
sounds.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# standard library
require 'io/console'
require 'yaml'
require 'ostruct'
require 'securerandom'
# gems
require 'awesome_print'
require 'colored'
require 'active_support/all'
# debugging gems
require 'byebug'
# extensions to ruby
require_relative "./core_util.rb"
# Base module extended by other files
module Sounds; end
# Require those other files
Dir.glob("./lib/*.rb").each { |path| require path }
# initialize with a tempo
$tempo_bpm = ENV["Tempo"] || 300.0
# start with the metronome off
$is_metronome_playing = false
# 8 beats is the default "time signature" (this is used by metronome)
$time_signature = ENV["TimeSignature"]&.to_i || 4.0
# start with recording off
$is_recording = false
# the most recent recording can be toggled on/off with /p
$is_last_recording_playing = false
# When including Sounds, some other modules/constants are loaded as well
# see lib/base.rb
module Sounds
def self.included(base)
super
base.class_exec do
include Sounds::Base
end
end
def with_n_input_threads(n, &blk)
n.times { Thread.new { blk.call } }
end
end
class SoundsRunner
include Sounds
def initialize
puts introduction
# with_n_input_threads(20) { loop_input }
loop_input
# loop { sleep }
end
end
# Run this unless the script is required
if __FILE__ == $0
SoundsRunner.new
end