Class: LiveSet

Inherits:
Object
  • Object
show all
Defined in:
lib/live_set/live_set_class.rb,
lib/live_set/live_set_class_private.rb

Overview

Instance Method Summary collapse

Constructor Details

#initialize(set_name, **options) ⇒ LiveSet

Returns a new instance of LiveSet.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/live_set/live_set_class.rb', line 11

def initialize(set_name, **options)
  @loglevel  = "-loglevel #{options[:loglevel]}"
  @loglevel += ' -stats' unless options[:loglevel] == 'quiet'
  @overwrite = options[:force]
  @set_name = set_name
  @contents = Zlib::GzipReader.open(set_name, &:readlines)
  @xml_doc = Nokogiri::Slop @contents.join("\n")

  @ableton = @xml_doc.Ableton
  @minor_version = @ableton['MinorVersion']

  @live_set = @ableton.LiveSet
  @tracks = AllTracks.new @live_set.Tracks.AudioTrack
  @scenes = @live_set.Scenes.map { |scene| LiveScene.new scene }
end

Instance Method Details

#modify_alsObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/live_set/live_set_class.rb', line 40

def modify_als
  if @minor_version.start_with? '11.'
    puts 'The Live set is already compatible with Live 11.'
    exit
  end

  @ableton['Creator'] = 'Ableton Live 11.3.21'
  @ableton['MajorVersion'] = '5'
  @ableton['MinorVersion'] = '11.0_11300'
  @ableton['Revision'] = '5ac24cad7c51ea0671d49e6b4885371f15b57c1e'
  @ableton['SchemaChangeCount'] = '3'

  ['//ContentLanes', '//ExpressionLanes', '//InstrumentMeld', '//Roar', '//MxPatchRef'].each do |element|
    @xml_doc.xpath(element).remove
  end
  new_contents = @xml_doc.to_xml.to_s
  new_contents.gsub! 'AudioOut/Main', 'AudioOut/Master'

  set_path = File.dirname @set_name
  new_set_name = File.basename @set_name, '.als'
  new_set_path = File.join set_path, "#{new_set_name}_11.als"
  if @overwrite
    puts "Overwriting existing #{new_set_path}"
    File.delete new_set_path
  else
    puts "Writing #{new_set_path}"
  end
  Zlib::GzipWriter.open(new_set_path) { |gz| gz.write new_contents }
end

#showObject



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/live_set/live_set_class.rb', line 27

def show
  check_abelton_project_info
  puts <<~END_SHOW
    #{@set_name}
      Created by #{@ableton['Creator']}
      Major version #{@ableton['MajorVersion']}
      Minor version v#{@minor_version}
      SchemaChangeCount #{@ableton['SchemaChangeCount']}
      Revision #{@ableton['Revision']}
    #{@tracks.message}
  END_SHOW
end