class Object
Constants
- RECORDER
Public Instance Methods
Frame(opts)
click to toggle source
# File lib/trecs/frame.rb, line 57 def Frame(opts) case opts when TRecs::Frame then opts else TRecs::Frame.new(opts) end end
finish(opts)
click to toggle source
# File bin/trecs, line 10 def finish(opts) puts "Finished" puts "Replay with:" puts "trecs #{opts[:trecs_backend]}" end
start_sound_player(file_name='sound.ogg')
click to toggle source
AUDIO ##########
# File bin/trecs, line 45 def start_sound_player(file_name='sound.ogg') return unless File.exist?(file_name) # at_exit { system('stty echo') } STDOUT.puts "=> Starting sound player..." @sox_pid = fork do `play #{file_name} 2>&1` end end
start_sound_recording(file_name='/tmp/sound.ogg')
click to toggle source
AUDIO ##########
# File bin/trecs_record, line 46 def start_sound_recording(file_name='/tmp/sound.ogg') puts "Sound file stored in #{file_name}" @sox_pid = fork do Signal.trap("SIGINT") { puts "=> Sound recording finished!" exit } sleep 0.5 `rec -C 1 --channels 1 --rate 16k --comment 'TRecs' #{file_name} 2>&1` end end
stop_sound_player()
click to toggle source
# File bin/trecs, line 54 def stop_sound_player return unless File.exist?(file_name) STDOUT.puts "=> Stopping sound player..." Process.waitpid(@sox_pid) end
stop_sound_recording()
click to toggle source
# File bin/trecs_record, line 58 def stop_sound_recording puts "=> Stopping sound recorder" sleep 2 # otherwise record will be cropped for some reason Process.kill("SIGINT", @sox_pid) Process.waitpid(@sox_pid) end