Skip to content

Commit

Permalink
Merge pull request #69 from amiaopensource/filename-to-gui
Browse files Browse the repository at this point in the history
rework gui/order
  • Loading branch information
privatezero authored Apr 4, 2018
2 parents 6cb0f99 + 03cc4aa commit 6dc20fe
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions audiorecorder2-dev/audiorecorder2/audiorecorder2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
$codec_choice = 'pcm_s24le'
$soxbuffer = '50000'
$sample_rate_choice = '96000'
$filename = ''

# Load options from config file
configuration_file = File.expand_path('~/.audiorecorder2.conf')
Expand Down Expand Up @@ -71,7 +72,7 @@ def BufferCheck(sr)
end

# GUI App
Shoes.app(title: "AudioRecorder2", width: 600, height: 520) do
Shoes.app(title: "AudioRecorder2", width: 600, height: 625) do
style Shoes::Para, font: "Helvetica"
background aliceblue
@logo = image("Resources/audiorecorder_small_1.png", left: 160)
Expand All @@ -84,7 +85,7 @@ def BufferCheck(sr)
end

def PostRecord(targetfile)
window(title: "Post-Record Options", width: 600, height: 550) do
window(title: "Post-Record Options", width: 600, height: 560) do
style Shoes::Para, font: "Helvetica"
background aliceblue
trimcheck = nil
Expand Down Expand Up @@ -252,13 +253,28 @@ def SetUpTrim(input)
end
end

stack margin: 10 do
button "Choose File Name" do
$filename = ask("Please Enter File Name")
if $filename == ''
@outputfile.replace "#{$filename}"
else
@outputfile.replace "#{$filename}.wav"
end
end
flow do
output_prompt = para "File will be saved as:"
@outputfile = para "#{$filename}", underline: "single"
end
end

flow do
preview = button "Preview"
preview.click do
BufferCheck($sample_rate_choice)
Soxcommand = 'rec -r ' + $sample_rate_choice + ' -b 32 -L -e signed-integer --buffer ' + $soxbuffer + ' -p remix ' + sox_channels
FFmpegSTART = 'ffmpeg -channel_layout ' + ffmpeg_channels + ' -i - '
FFmpegPreview = '-f wav -c:a ' + 'pcm_s16le' + ' -ar ' + '44100' + ' -'
FFmpegPreview = '-f wav -c:a ' + 'pcm_s16le -dither_method triangular' + ' -ar ' + '44100' + ' -'
FFplaycommand = 'ffplay -window_title "AudioRecorder" -f lavfi ' + '"' + 'amovie=\'pipe\:0\'' + ',' + FILTER_CHAIN + '"'
ffmpegcommand = FFmpegSTART + FFmpegPreview
command = Soxcommand + ' | ' + ffmpegcommand + ' | ' + FFplaycommand
Expand All @@ -275,14 +291,17 @@ def SetUpTrim(input)
$waveform_pic = 'AUDIORECORDERTEMP' + $record_iteration.to_s + '.png'

BufferCheck($sample_rate_choice)
filename = ask("Please Enter File Name")
@tempfileoutput = '"' + $outputdir + '/' + filename + '"'
@fileoutput = $outputdir + '/' + filename + '.wav'
if ! File.exist?(@fileoutput)
@tempfileoutput = '"' + $outputdir + '/' + $filename + '"'
@fileoutput = $outputdir + '/' + $filename + '.wav'
if $filename == ''
alert "Please enter an output file name!"
elsif File.exist?(@fileoutput)
alert "A File named #{$filename} already exists at that location!"
else
Soxcommand = 'rec -r ' + $sample_rate_choice + ' -b 32 -L -e signed-integer --buffer ' + $soxbuffer + ' -p remix ' + sox_channels
FFmpegSTART = 'ffmpeg -channel_layout ' + ffmpeg_channels + ' -i - '
FFmpegRECORD = '-f wav -c:a ' + $codec_choice + ' -ar ' + $sample_rate_choice + ' -metadata comment="" -y -rf64 auto ' + 'AUDIORECORDERTEMP.wav'
FFmpegPreview = ' -f wav -c:a ' + 'pcm_s16le' + ' -ar ' + '44100' + ' -'
FFmpegRECORD = '-f wav -c:a ' + $codec_choice + ' -dither_method triangular -ar ' + $sample_rate_choice + ' -metadata comment="" -y -rf64 auto ' + 'AUDIORECORDERTEMP.wav'
FFmpegPreview = ' -f wav -c:a ' + 'pcm_s16le -dither_method triangular' + ' -ar ' + '44100' + ' -'
FFplaycommand = 'ffplay -window_title "AudioRecorder" -f lavfi ' + '"' + 'amovie=\'pipe\:0\'' + ',' + FILTER_CHAIN + '"'
ffmpegcommand = FFmpegSTART + FFmpegRECORD + FFmpegPreview
syscommand1 = Soxcommand + ' | ' + ffmpegcommand + ' | ' + FFplaycommand
Expand All @@ -291,9 +310,7 @@ def SetUpTrim(input)
if $embedbext == 'true'
EmbedBEXT(@fileoutput)
end
PostRecord(@fileoutput)
else
alert "A File named #{filename} already exists at that location!"
PostRecord(@fileoutput)
end
end

Expand Down

0 comments on commit 6dc20fe

Please sign in to comment.