live_set 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 40ccc8116bfe826b52087a95ccdda582b948c7312be95eb282f17c5da7a24c86
4
+ data.tar.gz: e97386a24aa9dbcee91080e07cd2c9cc4331b65dab5b5080cbd0665b058de37a
5
+ SHA512:
6
+ metadata.gz: 90def6a620d141ee67449c7c4f66345d65aea8cad97a5ce0a37a8095e223b2ffc214825a5c10e81aa96e62c141fb6ba0df05cc0f3bb56bbf9f115238cad4fed3
7
+ data.tar.gz: 1f2e4ffa6e835d7021fe5e2d124a758b9cc629071cc1f5d1517cf20915640932966a433f867b92dc1083261aecb8b8fc748c5031dadaef0935a327af4ef9760a
data/.rubocop.yml ADDED
@@ -0,0 +1,59 @@
1
+ require:
2
+ - rubocop-md
3
+ - rubocop-performance
4
+ - rubocop-rake
5
+ - rubocop-rspec
6
+
7
+ AllCops:
8
+ Exclude:
9
+ - binstub/**/*
10
+ - exe/**/*
11
+ - vendor/**/*
12
+ - Gemfile*
13
+ NewCops: enable
14
+
15
+ Gemspec/DeprecatedAttributeAssignment:
16
+ Enabled: false
17
+
18
+ Gemspec/RequireMFA:
19
+ Enabled: false
20
+
21
+ Layout/HashAlignment:
22
+ EnforcedColonStyle: table
23
+ EnforcedHashRocketStyle: table
24
+
25
+ Layout/LineLength:
26
+ Max: 150
27
+
28
+ Metrics/AbcSize:
29
+ Max: 35
30
+
31
+ Metrics/BlockLength:
32
+ Exclude:
33
+ - live_set.gemspec
34
+ Max: 30
35
+
36
+ Metrics/CyclomaticComplexity:
37
+ Max: 15
38
+
39
+ Metrics/MethodLength:
40
+ Max: 40
41
+
42
+ Metrics/ModuleLength:
43
+ Enabled: false
44
+
45
+ Metrics/PerceivedComplexity:
46
+ Max: 15
47
+
48
+ Naming/FileName:
49
+ Exclude:
50
+ - Rakefile
51
+
52
+ Style/Documentation:
53
+ Enabled: false
54
+
55
+ Style/FrozenStringLiteralComment:
56
+ Enabled: false
57
+
58
+ Style/TrailingCommaInHashLiteral:
59
+ EnforcedStyleForMultiline: comma
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Change Log
2
+
3
+ ## 0.1.0
4
+
5
+ * Initial release.
data/README.md ADDED
@@ -0,0 +1,131 @@
1
+ # `Live_set` [![Gem Version](https://badge.fury.io/rb/live_set.svg)](https://badge.fury.io/rb/live_set)
2
+
3
+ This program can report the version of an Ableton Live set,
4
+ and it can changes an Ableton Live set from Live 12 format to Live 11 format.
5
+
6
+ This program has successfully converted the Ableton Live 12 demo project to Live 11.
7
+
8
+
9
+ ## Installation
10
+
11
+ Simply type:
12
+
13
+ ```shell
14
+ $ gem install live_set
15
+ ```
16
+
17
+
18
+ ## Usage
19
+
20
+ ```shell
21
+ $ live_set
22
+ Displays information about a Live set or converts a Live 12 set to Live 11 format.
23
+
24
+ Syntax: live_set OPTIONS PATH_TO_ALS_FILE
25
+
26
+ Environment variables used in PATH_TO_ALS_FILE are expanded.
27
+
28
+ Options are:
29
+ -11 Convert the Live 12 set to Live 11 format.
30
+ -f Overwrite any existing Live 11 set.
31
+ -h Display this help message.
32
+
33
+ Example:
34
+ live_set -11 -f $path/to/my_set.als
35
+ ```
36
+
37
+ ### Report
38
+
39
+ Report the version of the Ableton Live set:
40
+
41
+ ```shell
42
+ $ live_set $path/to/my_set.als
43
+ /mnt/c/media/Ableton/Projects/fu Project/fu.als
44
+ Created by Live v11.0_11300
45
+ Major version 11.0_11300
46
+ Revision 5ac24cad7c51ea0671d49e6b4885371f15b57c1e
47
+ SchemaChangeCount 3
48
+ Tracks:
49
+ Drums / complete
50
+ Bass
51
+ Guitar
52
+ Horns
53
+ Keys
54
+ Vocal Backing
55
+ Vocal Lead
56
+ Strings
57
+ ```
58
+
59
+
60
+ ### Convert
61
+
62
+ Make the Live 12 set compatible with Live 11 and save as `path/to/my_set_11.als`:
63
+
64
+ ```shell
65
+ $ live_set -11 -f path/to/my_set.als
66
+ ```
67
+
68
+
69
+ ## Development
70
+
71
+ After checking out this git repository, install dependencies by typing:
72
+
73
+ ```shell
74
+ $ bin/setup
75
+ ```
76
+
77
+ You should do the above before running Visual Studio Code.
78
+
79
+
80
+ ### Run the Tests
81
+
82
+ ```shell
83
+ $ bundle exec rake test
84
+ ```
85
+
86
+
87
+ ### Debug run
88
+
89
+ Define the `VO_DEBUGGING` environment variable so the code is loaded from the project
90
+ instead of attempting to load the `live_set` gem.
91
+
92
+ ```shell
93
+ $ VO_DEBUGGING=true ruby exe/live_set /path/to/my_set.als
94
+ ```
95
+
96
+ ### Interactive Session
97
+
98
+ The following will allow you to experiment:
99
+
100
+ ```shell
101
+ $ bin/console
102
+ ```
103
+
104
+
105
+ ### Local Installation
106
+
107
+ To install this gem onto your local machine, type:
108
+
109
+ ```shell
110
+ $ bundle exec rake install
111
+ ```
112
+
113
+
114
+ ### To Release A New Version
115
+
116
+ To create a git tag for the new version, push git commits and tags,
117
+ and push the new version of the gem to https://rubygems.org, type:
118
+
119
+ ```shell
120
+ $ bundle exec rake release
121
+ ```
122
+
123
+
124
+ ## Contributing
125
+
126
+ Bug reports and pull requests are welcome at https://github.com/mslinn/live_set.
127
+
128
+
129
+ ## License
130
+
131
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,40 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ desc 'Bump patch version'
11
+ task :patch do
12
+ system 'gem bump --tag'
13
+ end
14
+
15
+ desc 'Bump minor version'
16
+ task :minor do
17
+ system 'gem bump --version minor --tag'
18
+ end
19
+
20
+ desc 'Bump major version'
21
+ task :major do
22
+ system 'gem bump --version major --tag'
23
+ end
24
+
25
+ task publish: [:build] do
26
+ $VERBOSE = nil
27
+ load 'live_set/version.rb'
28
+ system "gem push pkg/live_set-#{LiveSet::VERSION}.gem"
29
+ end
30
+
31
+ desc 'Bump patch version, create git tag, build the gem and release to geminabox (default)'
32
+ task release_patch: %i[test patch publish]
33
+
34
+ desc 'Bump minor version, create git tag, build the gem and release to geminabox'
35
+ task release_minor: %i[test minor publish]
36
+
37
+ desc 'Bump major version, create git tag, build the gem and release to geminabox'
38
+ task release_major: %i[test major publish]
39
+
40
+ task default: :test
data/exe/live_set ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ if ENV['VO_DEBUGGING']
4
+ require_relative '../lib/live_set'
5
+ else
6
+ require 'live_set'
7
+ end
8
+
9
+ require 'colorator'
10
+ require_relative '../lib/options'
11
+
12
+ def common(command)
13
+ @options = parse_options command
14
+ help_show 'Ableton Live set name must be provided.' if ARGV.empty?
15
+ end
data/lib/common.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'colorator'
2
+ require_relative 'options'
3
+
4
+ def common(command)
5
+ @options = parse_options command
6
+ help_show 'The path for the Ableton Set must be provided.' if ARGV.empty?
7
+ end
8
+
9
+ def show
10
+ common :show
11
+ help_show "Too many parameters specified.\n#{ARGV}" if ARGV.length > 2
12
+
13
+ set_name = ARGV.join ' '
14
+ help "#{set_name} does not exist" unless File.exist? set_name
15
+ help "#{set_name} is a directory" if File.directory? set_name
16
+
17
+ LiveSet.new(set_name, **@options).show
18
+ end
@@ -0,0 +1,3 @@
1
+ module LiveSetVersion
2
+ VERSION = '0.1.0'.freeze unless defined? VERSION
3
+ end
data/lib/live_set.rb ADDED
@@ -0,0 +1,29 @@
1
+ require_relative 'live_set/version'
2
+
3
+ # Require all Ruby files in 'lib/', except this file
4
+ Dir[File.join(__dir__, '*.rb')].sort.each do |file|
5
+ # puts "Requiring #{file}"
6
+ require file unless file.end_with?('/live_set.rb')
7
+ end
8
+
9
+ def help(msg = nil)
10
+ puts "Error: #{msg}" if msg
11
+ puts 'List files in ableton set'
12
+ exit 1
13
+ end
14
+
15
+ help_show if ARGV.empty?
16
+
17
+ @options = parse_options
18
+
19
+ set_name = expand_env ARGV.join(' ')
20
+ help_show "#{set_name} does not exist" unless File.exist? set_name
21
+ help_show "#{set_name} is a directory" if File.directory? set_name
22
+
23
+ live_set = LiveSet.new set_name, **@options
24
+
25
+ if @options[:convert11]
26
+ live_set.modify_als
27
+ else
28
+ live_set.show
29
+ end
@@ -0,0 +1,96 @@
1
+ require 'nokogiri'
2
+ require 'zlib'
3
+
4
+ class String
5
+ def to_bool
6
+ return true if casecmp('true').zero?
7
+ return false if casecmp('false').zero?
8
+
9
+ nil
10
+ end
11
+ end
12
+
13
+ class LiveSet
14
+ def initialize(set_name, **options)
15
+ @loglevel = "-loglevel #{options[:loglevel]}"
16
+ @loglevel += ' -stats' unless options[:loglevel] == 'quiet'
17
+ @overwrite = options[:force]
18
+ @set_name = set_name
19
+ @contents = Zlib::GzipReader.open(set_name, &:readlines)
20
+ @xml_doc = Nokogiri::Slop @contents.join("\n")
21
+
22
+ @ableton = @xml_doc.Ableton
23
+ @minor_version = @ableton['MinorVersion']
24
+ end
25
+
26
+ def show
27
+ puts <<~END_SHOW
28
+ #{@set_name}
29
+ Created by #{@ableton['Creator']}
30
+ Major version #{@ableton['MajorVersion']}
31
+ Minor version v#{@minor_version}
32
+ SchemaChangeCount #{@ableton['SchemaChangeCount']}
33
+ Revision #{@ableton['Revision']}
34
+ END_SHOW
35
+ tracks = @ableton.LiveSet.Tracks.AudioTrack
36
+ track_msg = if tracks.empty?
37
+ 'No tracks'
38
+ else
39
+ all_frozen = all_tracks_frozen(tracks)
40
+ track_summary(tracks) +
41
+ tracks.map { |x| show_track x, all_frozen }.join("\n ")
42
+ end
43
+ puts track_msg
44
+ end
45
+
46
+ def modify_als
47
+ if @minor_version.start_with? '11.'
48
+ puts 'The Live set is already compatible with Live 11.'
49
+ exit
50
+ end
51
+
52
+ @ableton['Creator'] = 'Ableton Live 11.3.21'
53
+ @ableton['MajorVersion'] = '5'
54
+ @ableton['MinorVersion'] = '11.0_11300'
55
+ @ableton['Revision'] = '5ac24cad7c51ea0671d49e6b4885371f15b57c1e'
56
+ @ableton['SchemaChangeCount'] = '3'
57
+
58
+ ['//ContentLanes', '//ExpressionLanes', '//InstrumentMeld', '//Roar', '//MxPatchRef'].each do |element|
59
+ @xml_doc.xpath(element).remove
60
+ end
61
+ new_contents = @xml_doc.to_xml.to_s
62
+ new_contents.gsub! 'AudioOut/Main', 'AudioOut/Master'
63
+
64
+ set_path = File.dirname @set_name
65
+ new_set_name = File.basename @set_name, '.als'
66
+ new_set_path = File.join set_path, "#{new_set_name}_11.als"
67
+ if @overwrite
68
+ puts "Overwriting existing #{new_set_path}"
69
+ File.delete new_set_path
70
+ else
71
+ puts "Writing #{new_set_path}"
72
+ end
73
+ Zlib::GzipWriter.open(new_set_path) { |gz| gz.write new_contents }
74
+ end
75
+
76
+ private
77
+
78
+ def all_tracks_frozen(tracks)
79
+ tracks.all? { |track| track_is_frozen track }
80
+ end
81
+
82
+ def track_is_frozen(track)
83
+ track.Freeze['Value'].to_bool
84
+ end
85
+
86
+ def track_summary(tracks)
87
+ all_frozen_msg = all_tracks_frozen(tracks) ? ' (All are frozen)' : ''
88
+ "#{tracks.count} tracks#{all_frozen_msg}:\n "
89
+ end
90
+
91
+ def show_track(audio_track, all_frozen)
92
+ name = audio_track.Name.EffectiveName['Value']
93
+ frozen = !all_frozen && track_is_frozen(audio_track) ? ' **frozen**' : ''
94
+ "#{name}#{frozen}"
95
+ end
96
+ end
data/lib/options.rb ADDED
@@ -0,0 +1,56 @@
1
+ require 'colorator'
2
+ require 'optparse'
3
+
4
+ VERBOSITY = %w[trace debug verbose info warning error fatal panic quiet].freeze
5
+
6
+ def help_show(msg = nil)
7
+ printf "Error: #{msg}\n\n".yellow unless msg.nil?
8
+ msg = <<~END_HELP
9
+ Displays information about a Live set or converts a Live 12 set to Live 11 format.
10
+
11
+ Syntax: live_set OPTIONS PATH_TO_ALS_FILE
12
+
13
+ Environment variables used in PATH_TO_ALS_FILE are expanded.
14
+
15
+ Options are:
16
+ -11 Convert the Live 12 set to Live 11 format.
17
+ -f Overwrite any existing Live 11 set.
18
+ -h Display this help message.
19
+
20
+ Example:
21
+ live_set -11 -f $path/to/my_v12_set.als
22
+ END_HELP
23
+ printf msg.cyan
24
+ exit 1
25
+ end
26
+
27
+ def parse_options
28
+ options = { loglevel: 'warning' }
29
+ opts = do_parse
30
+ opts.order!(into: options)
31
+
32
+ help_show "Invalid verbosity value (#{options[:verbose]}), must be one of one of: #{VERBOSITY.join ', '}." \
33
+ if options[:verbose] && !options[:verbose] in VERBOSITY
34
+
35
+ options
36
+ end
37
+
38
+
39
+ private
40
+
41
+ def do_parse
42
+ OptionParser.new do |parser|
43
+ parser.program_name = File.basename __FILE__
44
+ @parser = parser
45
+
46
+ parser.on('-11', '--convert11', 'Make a copy of the set that is compatible with Live 11')
47
+ parser.on('-f', '--force', 'Overwrite the output set if it already exists')
48
+ parser.on('-s', '--show', 'Display information about the Ableton Live set')
49
+ parser.on('-l', '--loglevel LOGLEVEL', Integer, "Logging level (#{VERBOSITY.join ', '})")
50
+ parser.on('-v', '--verbose VERBOSE', 'Zoom percentage')
51
+
52
+ parser.on_tail('-h', '--help', 'Show this message') do
53
+ help_show
54
+ end
55
+ end
56
+ end
data/lib/util.rb ADDED
@@ -0,0 +1,5 @@
1
+ def self.expand_env(str)
2
+ str.gsub(/\$([a-zA-Z_][a-zA-Z0-9_]*)|\${\g<1>}|%\g<1>%/) do
3
+ ENV.fetch(Regexp.last_match(1), nil)
4
+ end
5
+ end
data/live_set.gemspec ADDED
@@ -0,0 +1,36 @@
1
+ require_relative 'lib/live_set/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ host = 'https://github.com/mslinn/live_set'
5
+
6
+ spec.authors = ['Mike Slinn']
7
+ spec.bindir = 'exe'
8
+ spec.executables = %w[live_set]
9
+ spec.description = <<~END_DESC
10
+ Reports the version of an Ableton Live set, and optionally changes it to v11 format.
11
+ END_DESC
12
+ spec.email = ['mslinn@mslinn.com']
13
+ spec.files = Dir['.rubocop.yml', 'LICENSE.*', 'Rakefile', '{lib,spec}/**/*', '*.gemspec', '*.md']
14
+ spec.homepage = 'https://github.com/mslinn/live_set'
15
+ spec.license = 'MIT'
16
+ spec.metadata = {
17
+ 'allowed_push_host' => 'https://rubygems.org',
18
+ 'bug_tracker_uri' => "#{host}/issues",
19
+ 'changelog_uri' => "#{host}/CHANGELOG.md",
20
+ 'homepage_uri' => spec.homepage,
21
+ 'source_code_uri' => host,
22
+ }
23
+ spec.name = 'live_set'
24
+ spec.post_install_message = <<~END_MESSAGE
25
+
26
+ Thanks for installing #{spec.name}!
27
+
28
+ END_MESSAGE
29
+ spec.require_paths = ['lib']
30
+ spec.required_ruby_version = '>= 2.7'
31
+ spec.summary = 'Reports the version of an Ableton Live set, and optionally changes it to v11 format.'
32
+ spec.version = LiveSetVersion::VERSION
33
+
34
+ spec.add_dependency 'colorator'
35
+ spec.add_dependency 'nokogiri'
36
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: live_set
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mike Slinn
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-03-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: colorator
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: nokogiri
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: 'Reports the version of an Ableton Live set, and optionally changes it
42
+ to v11 format.
43
+
44
+ '
45
+ email:
46
+ - mslinn@mslinn.com
47
+ executables:
48
+ - live_set
49
+ extensions: []
50
+ extra_rdoc_files: []
51
+ files:
52
+ - ".rubocop.yml"
53
+ - CHANGELOG.md
54
+ - README.md
55
+ - Rakefile
56
+ - exe/live_set
57
+ - lib/common.rb
58
+ - lib/live_set.rb
59
+ - lib/live_set/version.rb
60
+ - lib/llive_set_class.rb
61
+ - lib/options.rb
62
+ - lib/util.rb
63
+ - live_set.gemspec
64
+ homepage: https://github.com/mslinn/live_set
65
+ licenses:
66
+ - MIT
67
+ metadata:
68
+ allowed_push_host: https://rubygems.org
69
+ bug_tracker_uri: https://github.com/mslinn/live_set/issues
70
+ changelog_uri: https://github.com/mslinn/live_set/CHANGELOG.md
71
+ homepage_uri: https://github.com/mslinn/live_set
72
+ source_code_uri: https://github.com/mslinn/live_set
73
+ post_install_message: |2+
74
+
75
+ Thanks for installing live_set!
76
+
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '2.7'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubygems_version: 3.5.6
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Reports the version of an Ableton Live set, and optionally changes it to
95
+ v11 format.
96
+ test_files: []
97
+ ...