Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
135 lines (121 sloc) 4.08 KB
#!/usr/bin/env ruby
# encoding: utf-8
# Converts jubeat memo to jubeat analyser format
input = ""
memoBlank = ''
memoBackBlank = ''
analyserSymbols = ['@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
analyserSymbolPrefix = ''
analyserSixSymbols = ['@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
analyserSixSymbolPrefix = ','
space = " "
groups = Array.new
group = Array.new
out = Array.new
ARGV.each_with_index do |item, i|
input = item if i == 0
end
abort("ERROR : No input specified") if input.empty?
abort("ERROR : Input not found") if !File.exists?(input)
File.foreach(input, :encoding => "UTF-8") do |line|
if /^\d+$/.match(line)
groups.push group
group = Array.new
elsif /^.{4}\s+/.match(line)
group.push line
end
end
# push last group if group is not empty
groups.push group unless group.empty?
# flush first empty line
groups.shift
# convert into jubeat analyser format
# front : beats' position
# back : beats' rhythm
groups.each_with_index do |a_group, index|
front = Array.new
back = Array.new
a_group.each do |line|
front.concat line[0..3].split('')
backside = line[/\|(.+)\|/, 1]
back.push(backside.split('')) unless backside.nil?
end
# replace with jubeat analyser symbols
back.each_with_index do |line, l|
isSix = line.length === 6 ? true : false
line.each_with_index do |item, i|
if item != memoBackBlank
if(isSix)
n = (l * 6) + i
front.map! do |x|
x == item ? "#{analyserSixSymbolPrefix}#{analyserSixSymbols[n]}" : x
end
else
n = (l * 4) + i
front.map! do |x|
x == item ? "#{analyserSymbolPrefix}#{analyserSymbols[n]}" : x
end
end
end
end
end
# fill space
front.map! do |x|
x == memoBlank ? "#{analyserSymbolPrefix}#{space}" : x
end
out.push "---------- #{index+1}"
while shifted = front.shift(4)
break if shifted.empty?
out.push shifted.join
end
end
# write result into output
# Set encoding to windows 1252
# (jubeat analyser cannot read utf-8)
output = File.basename(input, ".*") + "_jma.txt"
f = File.new(output, 'w:Windows-1252')
# write file attributes
f.write "// Generated by jubeat-memo-analyser\n"
f.write "// http://github.com/NarzE/jubeat-memo-analyser\n"
f.write '#title="songtitle"' + "\n"
f.write '#artist="songartist"' + "\n"
f.write '#jacket="songjacketimage.jpg"' + "\n"
f.write 'm="songfile.mp3"' + "\n"
f.write '// Offset' + "\n"
f.write 'o=0' + "\n"
f.write '// Beats' + "\n"
f.write 'b=4' + "\n"
f.write '// BPM' + "\n"
f.write 't=195' + "\n"
f.write "\n"
# write 'six' symbols timing
f.write "*#{analyserSixSymbolPrefix}@:0" + "\n"
f.write "*#{analyserSixSymbolPrefix}A:0.166667" + "\n"
f.write "*#{analyserSixSymbolPrefix}B:0.333333" + "\n"
f.write "*#{analyserSixSymbolPrefix}C:0.5" + "\n"
f.write "*#{analyserSixSymbolPrefix}D:0.666667" + "\n"
f.write "*#{analyserSixSymbolPrefix}E:0.833333" + "\n"
f.write "*#{analyserSixSymbolPrefix}F:1" + "\n"
f.write "*#{analyserSixSymbolPrefix}G:1.166667" + "\n"
f.write "*#{analyserSixSymbolPrefix}H:1.333333" + "\n"
f.write "*#{analyserSixSymbolPrefix}I:1.5" + "\n"
f.write "*#{analyserSixSymbolPrefix}J:1.666667" + "\n"
f.write "*#{analyserSixSymbolPrefix}K:1.833333" + "\n"
f.write "*#{analyserSixSymbolPrefix}L:2" + "\n"
f.write "*#{analyserSixSymbolPrefix}M:2.166667" + "\n"
f.write "*#{analyserSixSymbolPrefix}N:2.333333" + "\n"
f.write "*#{analyserSixSymbolPrefix}O:2.5" + "\n"
f.write "*#{analyserSixSymbolPrefix}P:2.666667" + "\n"
f.write "*#{analyserSixSymbolPrefix}Q:2.833333" + "\n"
f.write "*#{analyserSixSymbolPrefix}R:3" + "\n"
f.write "*#{analyserSixSymbolPrefix}S:3.166667" + "\n"
f.write "*#{analyserSixSymbolPrefix}T:3.333333" + "\n"
f.write "*#{analyserSixSymbolPrefix}U:3.5" + "\n"
f.write "*#{analyserSixSymbolPrefix}V:3.666667" + "\n"
f.write "*#{analyserSixSymbolPrefix}W:3.833333" + "\n"
f.write "\n"
# write data
out.each do |line|
f.write("#{line}\n");
end
f.close
Something went wrong with that request. Please try again.