@@ -161,10 +161,6 @@ def initialize(opts={})
161161 # use a value within the valid range for a 32 bit signed complement integer
162162 @daemon_token = rand ( -2147483647 ..2147483647 )
163163
164- Util . open_log
165- Util . log "Welcome to the Daemon Booter"
166- Util . log "----------------------------\n "
167-
168164 if @no_scsynth_inputs
169165 Util . log "SuperCollider inputs disabled by GUI"
170166 else
@@ -220,6 +216,7 @@ def initialize(opts={})
220216
221217 Util . log "Booting Scsynth"
222218 @scsynth_booter = ScsynthBooter . new ( @ports , @no_scsynth_inputs )
219+ Util . log "Extracting Scsynth info"
223220 success , info = @scsynth_booter . read_info
224221 if success
225222 Thread . new do
@@ -283,7 +280,7 @@ def extract_scsynth_log_info_macos(info)
283280 # SC_AudioDriver: sample rate = 48000.000000, driver's block size = 32
284281 # SuperCollider 3 server ready.
285282
286- res = info . match /.*"(.*)" Input Device\s +Streams: [0-9]+\s +0\s +channels (.*)\s +"(.*)" Output Device\s +Streams: [0-9]+\s +0\s +channels (.*)\s /
283+ res = info . match /.*^ "(.*)" Input Device\s +Streams: [0-9]+\s +0\s +channels (.*)\s +^ "(.*)" Output Device\s +Streams: [0-9]+\s +0\s +channels (.*)\s /u
287284
288285 ##<MatchData
289286 # "\"MacBook Pro Microphone\" Input Device\n Streams: 1\n 0 channels 1\n\n\"MacBook Pro Speakers\" Output Device\n Streams: 1\n 0 channels 2\n"
@@ -319,7 +316,7 @@ def extract_scsynth_log_info_macos(info)
319316 info_m = { }
320317 end
321318
322- res2 = info . match /.*SC_AudioDriver: sample rate = (.*), driver's block size = (.*)\s / #'
319+ res2 = info . match /.*SC_AudioDriver: sample rate = (.*), driver's block size = (.*)\s /u #'
323320
324321 ##<MatchData "SC_AudioDriver: sample rate = 48000.000000, driver's block size = 32\n" 1:"48000.000000" 2:"32">
325322
@@ -394,11 +391,11 @@ def extract_scsynth_log_info_windows(info)
394391 # SuperCollider 3 server ready.
395392
396393 booting_with = info . split ( "Booting with" ) [ 1 ] || ""
397- res = booting_with . match /^\s +In: (.*?)\s +Out: (.*?)\s +Sample rate: (.*?)\s +Latency \( in\/ out\) : (.*) \/ (.*) sec/
394+ res = booting_with . match /^\s +In: (.*?)^ \s +Out: (.*?)^ \s +Sample rate: (.*?)^ \s +Latency \( in\/ out\) : (.*) \/ (.*) sec/u
398395
399- res_no_input = booting_with . match /^\s +Out: (.*?)\s +Sample rate: (.*?)\s +Latency \( in\/ out\) : (.*) \/ (.*) sec/
396+ res_no_input = booting_with . match /^\s +Out: (.*?)^ \s +Sample rate: (.*?)^ \s +Latency \( in\/ out\) : (.*) \/ (.*) sec/u
400397
401- res_no_output = booting_with . match /^\s +In: (.*?)\ s +Sample rate: (.*?)\s +Latency \( in\/ out\) : (.*) \/ (.*) sec/
398+ res_no_output = booting_with . match /^\s +In: (.*?)^ s+Sample rate: (.*?)^ \s +Latency \( in\/ out\) : (.*) \/ (.*) sec/u
402399 #<MatchData
403400 # " In: ASIO : MOTU Pro Audio\n Out: ASIO : MOTU Pro Audio\n Sample rate: 48000.000\n Latency (in/out): 0.003 / 0.004 sec"
404401 # 1:"ASIO : MOTU Pro Audio"
@@ -438,7 +435,7 @@ def extract_scsynth_log_info_windows(info)
438435 info_m = { }
439436 end
440437
441- res2 = booting_with . match /.*SC_AudioDriver: sample rate = (.*), driver's block size = (.*)\s / #'
438+ res2 = booting_with . match /.*SC_AudioDriver: sample rate = (.*), driver's block size = (.*)\s /u #'
442439
443440 ##<MatchData "SC_AudioDriver: sample rate = 48000.000000, driver's block size = 64\n" 1:"48000.000000" 2:"64">
444441
@@ -464,7 +461,7 @@ def extract_scsynth_log_info_linux(info)
464461 # SC_AudioDriver: sample rate = 48000.000000, driver's block size = 2048
465462 # SuperCollider 3 server ready."
466463
467- res = info . match ( /.*sample rate = (.*?), driver's block size = (.*?)\n SuperCollider 3/ )
464+ res = info . match ( /.*sample rate = (.*?), driver's block size = (.*?)\n SuperCollider 3/u )
468465
469466 if res
470467 return { sc_sample_rate : res [ 1 ] . to_i , sc_block_size : res [ 2 ] . to_i }
@@ -520,17 +517,21 @@ def scsynth_log_str(info_m)
520517 end
521518
522519 def send_scsynth_info_to_gui! ( info_s )
523-
524- info_m = extract_scsynth_log_info ( info_s )
525- hw_info_s = scsynth_log_str ( info_m )
526-
527- Util . log "Sending scsynth info to GUI..."
528- Util . log "\n Raw:\n ---\n #{ info_s } "
529- Util . log "\n Extracted:\n ---------\n #{ info_m . to_s } "
530- Util . log "\n Pretty:\n ------\n #{ hw_info_s } "
531- Util . log "\n ---\n "
532-
533- @api_server . send ( "localhost" , @ports [ "gui-listen-to-spider" ] , "/scsynth/info" , hw_info_s )
520+ begin
521+ info_m = extract_scsynth_log_info ( info_s )
522+ hw_info_s = scsynth_log_str ( info_m )
523+
524+ Util . log "Sending scsynth info to GUI..."
525+ Util . log "\n Raw:\n ---\n #{ info_s } "
526+ Util . log "\n Extracted:\n ---------\n #{ info_m . to_s } "
527+ Util . log "\n Pretty:\n ------\n #{ hw_info_s } "
528+ Util . log "\n ---\n "
529+
530+ @api_server . send ( "localhost" , @ports [ "gui-listen-to-spider" ] , "/scsynth/info" , hw_info_s )
531+ rescue => e
532+ Util . log "Exception sending scsynth info to gui:"
533+ Util . log_error ( e )
534+ end
534535 end
535536
536537 def boot_tau! ( wait_for_pid = true )
@@ -785,9 +786,11 @@ def boot
785786 @io_thr = Thread . new do
786787 @stdout_and_err . each do |line |
787788 begin
789+ line = line . force_encoding ( "UTF-8" )
788790 @log_file << line
789791 @log_file . flush
790792 @log << line if @record_log
793+ Util . log "log: #{ @log . encoding } , #{ line . encoding } , #{ line } "
791794 rescue IOError
792795 # don't attempt to write
793796 end
@@ -1448,15 +1451,18 @@ def find_free_port
14481451
14491452
14501453begin
1454+ SonicPi ::Daemon ::Util . open_log
1455+ SonicPi ::Daemon ::Util . log "Welcome to the Daemon Booter"
1456+ SonicPi ::Daemon ::Util . log "----------------------------\n "
1457+
14511458 if ARGV [ 0 ] == "--no-scsynth-inputs"
14521459 SonicPi ::Daemon ::Init . new ( no_scsynth_inputs : true )
14531460 else
14541461 SonicPi ::Daemon ::Init . new
14551462 end
1456-
1457-
1458-
14591463rescue StandardError => e
14601464 SonicPi ::Daemon ::Util . log "[BUG] - ** Daemon Internal Error. **"
14611465 SonicPi ::Daemon ::Util . log_error ( e )
1466+ else
1467+ SonicPi ::Daemon ::Util . log "Daemon Finished. Cheerio."
14621468end
0 commit comments