Skip to content

Commit 3935ff8

Browse files
committed
Spider - fix numerous parser warnings
Fixed indentation, removed unused code, added some extra error information.
1 parent 45c2d80 commit 3935ff8

File tree

8 files changed

+67
-98
lines changed

8 files changed

+67
-98
lines changed

app/server/ruby/core.rb

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,6 @@
3434

3535
require 'wavefile'
3636

37-
os = case RUBY_PLATFORM
38-
when /.*arm.*-linux.*/
39-
:raspberry
40-
when /.*linux.*/
41-
:linux
42-
when /.*darwin.*/
43-
:osx
44-
when /.*mingw.*/
45-
:windows
46-
else
47-
RUBY_PLATFORM
48-
end
49-
50-
5137
$:.unshift "#{File.expand_path("../rb-native", __FILE__)}/#{ruby_api}/"
5238

5339
module SonicPi
@@ -485,10 +471,6 @@ def filter(&block)
485471
self.class.new(@map.filter(&block))
486472
end
487473

488-
def select(&block)
489-
self.class.new(@map.select(&block))
490-
end
491-
492474
def flatten(*args)
493475
@map.flatten(*args)
494476
end

app/server/ruby/lib/sonicpi/lang/core.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3743,7 +3743,6 @@ def with_bpm_mul(mul, &block)
37433743
def use_bpm_mul(mul, &block)
37443744
raise ArgumentError, "use_bpm_mul must not be called with a block. Perhaps you meant with_bpm_mul" if block
37453745
raise ArgumentError, "use_bpm_mul's mul should be a positive value. You tried to use: #{mul}" unless mul > 0
3746-
new_bpm = __get_spider_bpm * mul.to_f
37473746
__layer_spider_time_density!(mul)
37483747
end
37493748
doc name: :use_bpm_mul,
@@ -3925,7 +3924,7 @@ def current_bpm_mode
39253924

39263925

39273926

3928-
def current_bpm
3927+
def current_bpm
39293928
__get_spider_bpm
39303929
end
39313930
doc name: :current_bpm,

app/server/ruby/lib/sonicpi/runtime.rb

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,6 @@ def __current_sched_ahead_time
382382

383383
def __schedule_delayed_blocks_and_messages!
384384
delayed_messages = __system_thread_locals.get(:sonic_pi_local_spider_delayed_messages, [])
385-
delayed_blocks = __system_thread_locals.get(:sonic_pi_local_spider_delayed_blocks, [])
386385
__system_thread_locals.set_local(:sonic_pi_local_spider_delayed_messages, [])
387386
__system_thread_locals.set_local(:sonic_pi_local_spider_delayed_blocks, [])
388387
if (delayed_messages && (!delayed_messages.empty?) && (!__system_thread_locals.get(:sonic_pi_spider_silent)))
@@ -399,17 +398,7 @@ def __schedule_delayed_blocks_and_messages!
399398
Thread.new do
400399
Kernel.sleep(sleep_time) if sleep_time > 0
401400
__msg_queue.push msg
402-
403-
#We're now in sync with the sched_ahead time
404-
405-
# delayed_blocks.each do |b|
406-
# begin
407-
# b.call
408-
# rescue => e
409-
# log e.backtrace
410-
# end
411-
# end
412-
401+
#We're now in sync with the sched_ahead time
413402
end
414403
end
415404
end

app/server/ruby/lib/sonicpi/scsynthexternal.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ def wait_for_boot
155155
puts "scsynth boot - Waiting for the SuperCollider Server to have booted..."
156156
p = Promise.new
157157

158-
booted = false
159158
connected = false
160159

161160
boot_s = OSC::UDPServer.new(0) do |a, b, info|
@@ -180,7 +179,7 @@ def wait_for_boot
180179
begin
181180
p.get(30)
182181
rescue Exception => e
183-
puts "scsynth boot - Unable to connect to SuperCollider Audio Server. Exiting..."
182+
puts "scsynth boot - Unable to connect to SuperCollider Audio Server (#{e.message}). Exiting..."
184183
exit
185184
ensure
186185
t.kill

app/server/ruby/lib/sonicpi/tau_api.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ def link_get_time_at_beat(beat, quantum = 4)
120120
def link_get_clock_time_at_beat(beat, quantum = 4)
121121
link_time = link_get_time_at_beat(beat, quantum)
122122
t_with_delta = (link_time + @link_time_delta_micros_prom.get) / 1_000_000.0
123+
t_with_delta
123124
end
124125

125126
def link_get_beat_at_clock_time(clock_time, quantum = 4)
@@ -200,32 +201,32 @@ def initialize_link_info!
200201
def add_incoming_api_handlers!
201202
@tau_comms.add_method("/link-tempo-change") do |args|
202203
@incoming_tempo_change_cv.broadcast
203-
gui_id = args[0]
204+
_gui_id = args[0]
204205
tempo = args[1].to_f
205206
@tempo = tempo
206207
end
207208

208209
@tau_comms.add_method("/midi-ins") do |args|
209-
gui_id = args[0]
210+
_gui_id = args[0]
210211
ins = args[1..-1]
211212
@updated_midi_ins_handler.call(ins)
212213
end
213214

214215
@tau_comms.add_method("/midi-outs") do |args|
215-
gui_id = args[0]
216+
_gui_id = args[0]
216217
outs = args[1..-1]
217218
@updated_midi_outs_handler.call(outs)
218219
end
219220

220221
@tau_comms.add_method("/tau-api-reply") do |args|
221-
gui_id = args[0]
222+
_gui_id = args[0]
222223
key = args[1]
223224
payload = args[2..-1]
224225
@tau_api_events.async_event(key, payload)
225226
end
226227

227228
@tau_comms.add_method("/internal-cue") do |args|
228-
gui_id = args[0]
229+
_gui_id = args[0]
229230
path = args[1]
230231
args = args[2..-1]
231232
@internal_cue_handler.call(path, args)
@@ -236,7 +237,7 @@ def add_incoming_api_handlers!
236237
end
237238

238239
@tau_comms.add_method("/external-osc-cue") do |args|
239-
gui_id = args[0]
240+
_gui_id = args[0]
240241
ip = args[0]
241242
port = args[1]
242243
address = args[2]

app/server/ruby/lib/sonicpi/tau_comms.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ def tau_ready?
101101
def wait_for_tau!
102102
p = Promise.new
103103

104-
booted = false
105104
connected = false
106105

107106
boot_s = OSC::UDPServer.new(0) do |a, b, info|
@@ -125,7 +124,7 @@ def wait_for_tau!
125124
begin
126125
p.get(30)
127126
rescue Exception => e
128-
STDOUT.puts "TauComms - Unable to connect to tau. Exiting..."
127+
STDOUT.puts "TauComms - Unable to connect to tau (#{e.message}). Exiting..."
129128
exit
130129
ensure
131130
t.kill

app/server/ruby/lib/sonicpi/util.rb

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module Util
2222
when /.*arm.*-linux.*/
2323
@@os = :raspberry
2424
when /aarch64.*linux.*/
25-
@@os = :raspberry
25+
@@os = :raspberry
2626
when /.*linux.*/
2727
@@os = :linux
2828
when /.*darwin.*/
@@ -101,7 +101,7 @@ def raspberry_pi_3bplus_64?
101101
os == :raspberry && @@raspberry_pi_3bplus_64
102102
end
103103

104-
def raspberry_pi_4_1gb?
104+
def raspberry_pi_4_1gb?
105105
os == :raspberry && @@raspberry_pi_4_1gb
106106
end
107107

@@ -125,23 +125,23 @@ def raspberry_pi_4_2gb_64?
125125
os == :raspberry && @@raspberry_pi_4_2gb_64
126126
end
127127

128-
def raspberry_pi_4_4gb_64?
128+
def raspberry_pi_4_4gb_64?
129129
os == :raspberry && @@raspberry_pi_4_4gb_64
130130
end
131131

132-
def raspberry_pi_4_8gb_64?
132+
def raspberry_pi_4_8gb_64?
133133
os == :raspberry && @@raspberry_pi_4_8gb_64
134134
end
135135

136-
def raspberry_pi_400?
136+
def raspberry_pi_400?
137137
os == :raspberry && @@raspberry_pi_400
138138
end
139139

140-
def raspberry_pi_400_64?
140+
def raspberry_pi_400_64?
141141
os == :raspberry && @@raspberry_pi_400_64
142142
end
143143

144-
def unify_tilde_dir(path)
144+
def unify_tilde_dir(path)
145145
if os == :windows
146146
path
147147
else
@@ -154,14 +154,14 @@ def num_buffers_for_current_os
154154
end
155155

156156
def num_audio_busses_for_current_os
157-
1024
157+
1024
158158
end
159159

160160
def default_sched_ahead_time
161161
if raspberry_pi_2?
162162
2
163163
elsif raspberry_pi_3? or raspberry_pi_3bplus? \
164-
or raspberry_pi_3_64? or raspberry_pi_3bplus_64?
164+
or raspberry_pi_3_64? or raspberry_pi_3bplus_64?
165165
1.5
166166
else
167167
0.5
@@ -197,11 +197,11 @@ def host_platform_desc
197197
"Raspberry Pi 4B:4Gb 64bit OS"
198198
elsif raspberry_pi_4_8gb_64?
199199
"Raspberry Pi 4B:8Gb 64bit OS"
200-
elsif raspberry_pi_400?
200+
elsif raspberry_pi_400?
201201
"Raspberry Pi 400:4Gb"
202202
elsif raspberry_pi_400_64?
203203
"Raspberry Pi 400:4Gb 64bit OS"
204-
else
204+
else
205205
"Raspberry Pi"
206206
end
207207
when :linux
@@ -215,7 +215,7 @@ def host_platform_desc
215215

216216
def default_control_delta
217217
if raspberry_pi?
218-
0.013
218+
0.013
219219
else
220220
0.005
221221
end
@@ -270,10 +270,10 @@ def __exe_fix(path)
270270
def fetch_url(url, anonymous_uuid=true)
271271
begin
272272

273-
params = {:ruby_platform => RUBY_PLATFORM,
274-
:ruby_version => RUBY_VERSION,
275-
:ruby_patchlevel => RUBY_PATCHLEVEL,
276-
:sonic_pi_version => @version.to_s}
273+
params = {:ruby_platform => RUBY_PLATFORM,
274+
:ruby_version => RUBY_VERSION,
275+
:ruby_patchlevel => RUBY_PATCHLEVEL,
276+
:sonic_pi_version => @version.to_s}
277277

278278
params[:uuid] = global_uuid if anonymous_uuid
279279

@@ -359,19 +359,19 @@ def resolve_synth_opts_hash_or_array(opts)
359359

360360
def truthy?(val)
361361

362-
case val
363-
when Numeric
364-
return val != 0
365-
when NilClass
366-
return false
367-
when TrueClass
368-
return true
369-
when FalseClass
370-
return false
371-
when Proc
372-
new_v = val.call
373-
return truthy?(new_v)
374-
end
362+
case val
363+
when Numeric
364+
return val != 0
365+
when NilClass
366+
return false
367+
when TrueClass
368+
return true
369+
when FalseClass
370+
return false
371+
when Proc
372+
new_v = val.call
373+
return truthy?(new_v)
374+
end
375375
end
376376

377377
def zipmap(a, b)

app/server/ruby/test/setup_test.rb

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -121,33 +121,33 @@ def initialize
121121
end
122122
end
123123

124-
external_osc_cue_handler = lambda do |time, ip, port, address, args|
125-
address = "/#{address}" unless address.start_with?("/")
126-
address = "/osc:#{host}:#{port}#{address}"
127-
p = 0
128-
d = 0
129-
b = 0
130-
m = 60
131-
@register_cue_event_lambda.call(Time.now, p, @system_init_thread_id, d, b, m, address, args, 0)
132-
end
133-
134-
internal_cue_handler = lambda do |path, args|
135-
p = 0
136-
d = 0
137-
b = 0
138-
m = 60
139-
@register_cue_event_lambda.call(Time.now, p, @system_init_thread_id, d, b, m, address, args, 0)
140-
end
141-
142-
updated_midi_ins_handler = lambda do |ins|
143-
desc = ins.join("\n")
144-
__msg_queue.push({:type => :midi_in_ports, :val => desc})
145-
end
146-
147-
updated_midi_outs_handler = lambda do |outs|
148-
desc = outs.join("\n")
149-
__msg_queue.push({:type => :midi_out_ports, :val => desc})
150-
end
124+
# external_osc_cue_handler = lambda do |time, ip, port, address, args|
125+
# address = "/#{address}" unless address.start_with?("/")
126+
# address = "/osc:#{host}:#{port}#{address}"
127+
# p = 0
128+
# d = 0
129+
# b = 0
130+
# m = 60
131+
# @register_cue_event_lambda.call(Time.now, p, @system_init_thread_id, d, b, m, address, args, 0)
132+
# end
133+
134+
# internal_cue_handler = lambda do |path, args|
135+
# p = 0
136+
# d = 0
137+
# b = 0
138+
# m = 60
139+
# @register_cue_event_lambda.call(Time.now, p, @system_init_thread_id, d, b, m, address, args, 0)
140+
# end
141+
142+
# updated_midi_ins_handler = lambda do |ins|
143+
# desc = ins.join("\n")
144+
# __msg_queue.push({:type => :midi_in_ports, :val => desc})
145+
# end
146+
147+
# updated_midi_outs_handler = lambda do |outs|
148+
# desc = outs.join("\n")
149+
# __msg_queue.push({:type => :midi_out_ports, :val => desc})
150+
# end
151151

152152
# @tau_api = TauAPI.new(ports,
153153
# {

0 commit comments

Comments
 (0)