class Renoise::Repl
Constants
- BPM
- CONFIGURATION
- LS
- NOTES
- RESERVED
- RM
- SEQUENCE
Public Class Methods
new()
click to toggle source
# File lib/renoise/repl.rb, line 29 def initialize puts "Renoise Repl ... Bootup" puts "Please be aware to Start Renoise-OSC Server in UDP-Mode" @host = Readline.readline("Host: ", true) @port = Readline.readline("Port: ", true).to_i print "Setup connection ... " @renoise = Renoise::Core.new(@host, @port) puts "Done" print "Setup BPM to 120 ... " @renoise.bpm = 120 puts "Done" repl @renoise.seq_stop @renoise.panic puts "Good Bye :)" end
Public Instance Methods
bpm()
click to toggle source
# File lib/renoise/repl.rb, line 109 def bpm i = @input.match(BPM) bpm = i[1].to_i @renoise.bpm = bpm end
configuration()
click to toggle source
# File lib/renoise/repl.rb, line 154 def configuration i = @input.match(CONFIGURATION) name = i[1] unless @renoise.seq_status[:sequencers].include? name then puts "Sorry, sequence doesn't exist." return end config = i[2].split(/\s+/i).map { |c| c =~ /^\d+$/ ? c.to_i : c } (config.length / 2).times do |i| @renoise.config name, { config[i*2].to_sym => config[(i*2) + 1] } end list end
list()
click to toggle source
# File lib/renoise/repl.rb, line 168 def list status = @renoise.seq_status puts "\n#{ status[:play] ? 'PLAYING' : 'STOPPED' } Takt: #{ status[:position] / 4 + 1 } Note: #{ status[:position] % 4 + 1}" temp_show_seq = Class.new do def initialize(k, v) @name = k @instr = v[:instrument] @track = v[:track] @value = v[:value] @basenote = v[:basenote] @beat = v[:beat] @length = v[:length] @notes = v[:notes].map { |n| note_to_s(n) } end def note_to_s(note) if note < 0 then return "-" end b = %w{c c# d d# e f f# g g# a a# h}[note % 12] b += note / 12 < 1 ? '' : (note / 12).to_s return b end def to_s "\n-- #{ @name } --\ninstrument=#{ @instr } track=#{ @track }\nbeat=#{ @beat } basenote=#{ @basenote } value=#{ @value} length=#{ @length }\n#{ @notes.join(' ') }" end end status[:sequencers].each do |k, v| puts temp_show_seq.new(k, v) end puts end
note_to_s(note)
click to toggle source
# File lib/renoise/repl.rb, line 184 def note_to_s(note) if note < 0 then return "-" end b = %w{c c# d d# e f f# g g# a a# h}[note % 12] b += note / 12 < 1 ? '' : (note / 12).to_s return b end
notes()
click to toggle source
# File lib/renoise/repl.rb, line 126 def notes # notes(name, *notes) i = @input.match(NOTES) name = i[1] unless @renoise.seq_status[:sequencers].include? name then puts "Sorry, sequence doesn't exist." return end notes = (i[2]).strip.split(/\s+/).map { |i| i.to_i } @renoise.notes name, *notes list end
panic()
click to toggle source
# File lib/renoise/repl.rb, line 105 def panic @renoise.panic end
repl()
click to toggle source
# File lib/renoise/repl.rb, line 49 def repl loop do begin input = Readline.readline(">> ", true) input = input.split(';').map { |s| s.strip } input.each do |iii| @input = iii if @input =~ /exit/i then return elsif @input =~ /^play/i then @renoise.seq_play elsif @input =~ /^pause/i then @renoise.seq_pause elsif @input =~ /^stop/i then @renoise.seq_stop elsif @input =~ /^panic/i then panic elsif @input =~ /^help/i then puts "- control -" puts "play <- Play" puts "pause <- Pause" puts "stop <- Stop" puts "panic <- Stops everything" puts "bpm <number> <- Set Beats per Minute" puts puts "- sequencer -" puts "<name> <basenote> <instrument> <track> <- create a sequence" puts "ls <- Linst sequences" puts "config <name> ...key val <- change configuration of sequence" puts "notes <name> <midinotes...> <- set notes (negative for silence)" puts "rm <seqname> <- Remove a sequence" elsif @input =~ RM then rm elsif @input =~ BPM then bpm elsif @input =~ LS then list elsif @input =~ NOTES then notes elsif @input =~ CONFIGURATION then configuration elsif @input =~ SEQUENCE then sequence else puts "no command." end end rescue => e puts "err" end end end
rm()
click to toggle source
# File lib/renoise/repl.rb, line 115 def rm i = @input.match(RM) name = i[1] unless @renoise.seq_status[:sequencers].include? name then puts "Sorry, sequence doesn't exist." return end @renoise.seq_drop name list end
sequence()
click to toggle source
# File lib/renoise/repl.rb, line 139 def sequence # seq(name, basenote, instr, track) i = @input.match(SEQUENCE) name = i[1] if RESERVED.include? name then puts "Sorry name is reserved." return end basenote = i[2].to_i instr = i[3].to_i track = i[4].to_i @renoise.seq name, basenote, instr, track list end
to_s()
click to toggle source
# File lib/renoise/repl.rb, line 193 def to_s "\n-- #{ @name } --\ninstrument=#{ @instr } track=#{ @track }\nbeat=#{ @beat } basenote=#{ @basenote } value=#{ @value} length=#{ @length }\n#{ @notes.join(' ') }" end